<%@ page language="java" pageEncoding="UTF-8" %>
<%@ page import="com.ncr.teradata.bireport.*" %>
<%@ page import="java.util.Enumeration" %>
<%
	Object userAuth = request.getSession().getAttribute("User_Auth");
	//if (userAuth != null && ((String)userAuth).trim().equals("2"))
	//	out.print("<script>document.location.href='camp_audit_detail.jsp';</script>");

	String cityCode = "1000";
	String countryCode = "";
	
	String campId = "";
	String campSeqId = "";
	String minDateId = "";
	String maxDateId = "";
	Enumeration e = request.getParameterNames();
	while (e.hasMoreElements())
	{
		String hdName = (String)e.nextElement();
		if (hdName.equals("campId"))
			campId = request.getParameter(hdName);
		if (hdName.equals("campSeqId"))
			campSeqId = request.getParameter(hdName);
		if (hdName.equals("minDateId"))
			minDateId = request.getParameter(hdName);
		if (hdName.equals("maxDateId"))
			maxDateId = request.getParameter(hdName);
	}
	
	Report report = new Report("CAMP_KPI_AUDIT",cityCode,countryCode);
	
	if(minDateId.equals(""))
		minDateId = CommonFunc.moveToDate((String)report.getDimensionMaxValue("Date_Id"),"yyyyMMdd",-14);
	if(maxDateId.equals(""))
		maxDateId = (String)report.getDimensionMaxValue("Date_Id");
	Object[] campIds = report.getDimensionValues("Camp_Id");
	Object[] campSeqIds = report.getDimensionValues("Camp_Seq_Id","Camp_Id",campId);
	Object[] dateIds = report.getDimensionValues("Date_Id");
%>

<html>
<head>
	<title>营销监控</title>
	<link href="../css/style.css" rel="stylesheet" type="text/css"/>
    <link href="../css/font.css" rel="stylesheet" type="text/css">
<SCRIPT>
	function campIdChg(campId){
		document.location.href = "camp_audit.jsp?campId=" + campId;
	}

	function campSeqIdChg(campSeqId){
		var minDateId = document.all.minDateId.value;
		var maxDateId = document.all.maxDateId.value;
		trendIFrame.location.href = "camp_audit_trend.jsp?campId=<%= campId %>&campSeqId=" + campSeqId + "&maxDateId=" + maxDateId + "&minDateId=" + minDateId;
		contRsltIFrame.location.href = "camp_audit_cont_rslt.jsp?campId=<%= campId %>&campSeqId=" + campSeqId + "&maxDateId=" + maxDateId + "&minDateId=" + minDateId;
	}
	
	function minDateIdChg(minDateId){
		var campSeqId = document.all.campSeqId.value;
		var maxDateId = document.all.maxDateId.value;
		trendIFrame.location.href = "camp_audit_trend.jsp?campId=<%= campId %>&campSeqId=" + campSeqId + "&maxDateId=" + maxDateId + "&minDateId=" + minDateId;
		contRsltIFrame.location.href = "camp_audit_cont_rslt.jsp?campId=<%= campId %>&campSeqId=" + campSeqId + "&maxDateId=" + maxDateId + "&minDateId=" + minDateId;
	}
	
	function maxDateIdChg(maxDateId){
		var campSeqId = document.all.campSeqId.value;
		var minDateId = document.all.minDateId.value;
		trendIFrame.location.href = "camp_audit_trend.jsp?campId=<%= campId %>&campSeqId=" + campSeqId + "&maxDateId=" + maxDateId + "&minDateId=" + minDateId;
		contRsltIFrame.location.href = "camp_audit_cont_rslt.jsp?campId=<%= campId %>&campSeqId=" + campSeqId + "&maxDateId=" + maxDateId + "&minDateId=" + minDateId;
	}
</SCRIPT>
</head>
<body>
	<table width="940" height="100%" border="0" align="center" valign="top" cellpadding="1" cellspacing="1" >
		<tr valign='top' height='30'>
			<td valign='top' align='left' width='100%' bgcolor="#FFFFFF" colspan='2'> 
				<table border=0 width="100%" class="tablestyle4" style='table-layout:' cellspacing='1' cellpadding='1' bordercolordark='#ffffff' bordercolorlight='#ffffff'>
					<tr class="fontblue" width="100%" align="left">
						<td align='left' valign='top'>
							营销活动：
                        	<select class="select" name="campId" style='width:100' onchange="campIdChg(this.value);">
								<option value="" <% if(campId.equals("")) out.print("selected"); %>>全部</option>
								<% for(int i = 0; i < campIds.length; i++){ %>
	    	                		<OPTION value="<%= (String)campIds[i] %>" <% if(((String)campIds[i]).equals(campId)) out.print("selected"); %>><%= report.getNameValueByID("Camp_Id","Camp_Name",(String)campIds[i]) %></OPTION>
	    	                	<% } %>
	    	            	</select>
                        </td>
						<td align='left' valign='top'>
							营销批次：
                        	<select class="select" name="campSeqId" style='width:120' onchange="campSeqIdChg(this.value);">
								<option value="" <% if(campSeqId.equals("")) out.print("selected"); %>>全部</option>
	    	                	<% for(int i = 0; i < campSeqIds.length; i++){ %>
	    	                		<OPTION value="<%= (String)campSeqIds[i] %>" <% if(((String)campSeqIds[i]).equals(campSeqId)) out.print("selected"); %>><%= report.getNameValueByID("Camp_Seq_Id","Camp_Seq_Name",(String)campSeqIds[i]) %></OPTION>
	    	                	<% } %>
	    	            	</select>
                        </td>
                        <td align='left' valign='top'>
                    		开始日期：
                        	<select class="select" name="minDateId" style='width:100' onchange="minDateIdChg(this.value);">
	    	                	<% for(int i = dateIds.length - 1; i >= 0; i--){ %>
	    	                		<OPTION value="<%= (String)dateIds[i] %>" <% if(((String)dateIds[i]).equals(minDateId)) out.print("selected"); %>><%= (String)dateIds[i] %></OPTION>
	    	                	<% } %>
	    	            	</select>
                        </td>
                        <td align='left' valign='top'>
                    		结束日期：
	    	            	<select class="select" name="maxDateId" style='width:100' onchange="maxDateIdChg(this.value);">
	    	                	<% for(int i = dateIds.length - 1; i >= 0; i--){ %>
	    	                		<OPTION value="<%= (String)dateIds[i] %>" <% if(((String)dateIds[i]).equals(maxDateId)) out.print("selected"); %>><%= (String)dateIds[i] %></OPTION>
	    	                	<% } %>
	    	            	</select>
                        </td>
                        <td width='20%' align='left'>
                        	&nbsp;&nbsp;
                    	</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr valign='top' height='710'>
			<td valign='top' align='left' width='65%' bgcolor="#FFFFFF"> 
				<div align="center" id="div1" style="display: block">
					<iframe name="trendIFrame" align="middle" frameborder="0" width="100%" height="710"
						src="camp_audit_trend.jsp?campId=<%= campId %>&campSeqId=<%= campSeqId %>&minDateId=<%= minDateId %>&maxDateId=<%= maxDateId %>"></iframe>
				</div>
			</td>
			<td width='35%'>
				<div align="center" id="div2" style="display: block">
					<iframe name="contRsltIFrame" align="middle" frameborder="0" width="100%" height="710"
						src="camp_audit_cont_rslt.jsp?campId=<%= campId %>&campSeqId=<%= campSeqId %>&minDateId=<%= minDateId %>&maxDateId=<%= maxDateId %>"></iframe>
				</div>
			</td>
		</tr>
		<tr valign='top'>
			<td valign='top' align='left' width='65%' bgcolor="#FFFFFF" colspan='2'> 
				&nbsp;
			</td>
		</tr>
	</table>
</body>
</html>